execCommandAndCapture

suspend fun execCommandAndCapture(command: String, vararg args: String, cwd: Path? = null, env: Map<String, String>? = null, input: <ERROR CLASS>? = null, silent: Boolean = false, outStream: <ERROR CLASS>? = null, errStream: <ERROR CLASS>? = null, windowsVerbatimArguments: Boolean = false, failOnStdErr: Boolean = false, ignoreReturnCode: Boolean = false, delay: Long = 10000, stdoutListener: (<ERROR CLASS>) -> Unit? = null, stderrListener: (<ERROR CLASS>) -> Unit? = null, stdoutLineListener: (data: String) -> Unit? = null, stderrLineListener: (data: String) -> Unit? = null, debugListener: (data: String) -> Unit? = null): ExecResult

Execute a command and capture stdout and stderr.

Output redirection and pipes do not appear to be supported, but you can set outStream using Path.readStream (see actions/toolkit#359. However, this will write the command as the first line (see actions/toolkit#649).

To workaround, you can use execShell.

Parameters

command

command to execute (can include additional args). Must be correctly escaped.

args

optional arguments for tool. Escaping is handled by the lib.

cwd

the working directory

env

the environment. Uses the current environment by default.

input

input to write to the subprocess's stdin

silent

whether to hide output

outStream

the output stream to use. Defaults to process.stdout.

errStream

the error stream to use. Defaults to process.stderr.

windowsVerbatimArguments

whether to skip escaping arguments for Windows

failOnStdErr

whether to fail if output is send to stderr

ignoreReturnCode

whether to not fail the process if the subprocess fails. False by default.

delay

How long in ms to wait for STDIO streams to close after the exit event of the process before terminating

stdoutListener

listener for stdout output

stderrListener

listener for stderr output

stdoutLineListener

listener for stdout output, called per line

stderrLineListener

listener for stderr output, called per line

debugListener

listener for debug output

Sources

js source
Link copied to clipboard